package com.tulele.vtool.task.process;

import com.tulele.vtool.bus.model.UserInfo;
import com.tulele.vtool.bus.service.IUserService;
import com.tulele.vtool.task.async.UserDailyBrandSetInfoPushAsyncTask;
import com.tulele.vtool.util.SpringContextUtil;
import lombok.extern.slf4j.Slf4j;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.stereotype.Component;

import java.util.List;

@Slf4j
@Component
public class UserDailyBrandSetInfoPushScheTask extends QuartzJobBean {

    @Autowired
    private UserDailyBrandSetInfoPushAsyncTask userDailyBrandSetInfoPushAsyncTask;

    @Autowired
    private IUserService userService;

    @Value("${spring.application.name}")
    private String springProfilesActive;

    @Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {

//        int userTotalCount = Optional.ofNullable(userService.getLastestUserId()).orElse(10500000) + 10;
//
//        int minUserId = Optional.ofNullable(userService.getOldestUserId()).orElse(10000000);
//
//        for (int i = minUserId; i <= userTotalCount; i++) {
//
//            userDailyBrandSetInfoPushAsyncTask.execute("wxPushUser" + i);
//
//        }

        String profile = springProfilesActive;//获取环境
        List<UserInfo> userList=userService.getUserListByGzhCode(profile);
        for (UserInfo userInfo : userList) {
//            userDailyBrandSetInfoPushAsyncTask.execute(userInfo,profile);
        }

    }

}
